{% extends "base_generic.html" %}
{% block script %}
<script type="text/javascript">
  function generateUrl(name) {
    var sanitizedName = name;
    sanitizedName = sanitizedName.replace(/ el /gi, ' ');
    sanitizedName = sanitizedName.replace(/ la /gi, ' ');
    sanitizedName = sanitizedName.replace(/ los /gi, ' ');
    sanitizedName = sanitizedName.replace(/ las /gi, ' ');
    sanitizedName = sanitizedName.replace(/ de /gi, ' ');
    sanitizedName = sanitizedName.replace(/ del /gi, ' ');
    sanitizedName = sanitizedName.replace(/ temporada /gi, ' ');
    sanitizedName = sanitizedName.replace(/--/gi, '-');
    sanitizedName = sanitizedName.replace(/---/gi, '-');
    sanitizedName = sanitizedName.replace(/----/gi, '-');
    sanitizedName = string_to_slug(sanitizedName);
    $("#countrySlug").val(sanitizedName);
  }
  function generateUrl2(name) {
    var sanitizedName = name;
    sanitizedName = sanitizedName.replace(/ el /gi, ' ');
    sanitizedName = sanitizedName.replace(/ la /gi, ' ');
    sanitizedName = sanitizedName.replace(/ los /gi, ' ');
    sanitizedName = sanitizedName.replace(/ las /gi, ' ');
    sanitizedName = sanitizedName.replace(/ de /gi, ' ');
    sanitizedName = sanitizedName.replace(/ del /gi, ' ');
    sanitizedName = sanitizedName.replace(/ temporada /gi, ' ');
    sanitizedName = sanitizedName.replace(/--/gi, '-');
    sanitizedName = sanitizedName.replace(/---/gi, '-');
    sanitizedName = sanitizedName.replace(/----/gi, '-');
    sanitizedName = string_to_slug(sanitizedName);
    $("#competitionSlug").val(sanitizedName);
  }
</script>
{% endblock %}
{% block content %}
        <h1>Cita</h1>
        <form action="/admin/sellos/{{ key }}/save/" method="post">
        <div class="line">
          <div class="field">
            <label for="mainimage">Foto principal:</label>
            <div id="mainimage" class="inputimg"></div>
          </div>
        </div>
        <div class="line">
          <div class="field">
            <label>Year:</label>
            <input id="year" name="year" type="text" size="4" value="{{ year }}" />
          </div>
          <div class="field">
            <label>Country:</label>
            <input type="text" name="country" value="{{ country }}" id="country"  onblur="generateUrl(this.value);" />
          </div>
          <div class="field" style="display: none;">
            <label>Country Slug:</label>
            <input type="text" name="countrySlug" value="{{ countrySlug }}" id="countrySlug" size="20" />
          </div>
           <div class="field">
             <label>Competition:</label>
             <input type="text" name="competition" value="{{ competition }}" id="competition"  onblur="generateUrl2(this.value);" />
           </div>
           <div class="field" style="display: none;">
             <label>Competition Slug:</label>
             <input type="text" name="competitionSlug" value="{{ competitionSlug }}" id="competitionSlug" size="20" />
           </div>
        </div>
        <input type="hidden" name="codenum" id="codenum" value="{{ filekey }}" />
        <input type="submit" value="Guardar" id="save" name="save" name="save" /><br class="clear" />
      </form>
      <br class="clear" />

{% endblock %}
      